ul_jsonwrt_value_boolean (jo, "rollback", is_rollback);
ul_jsonwrt_value_boolean (jo, "finalization-locked",
ostree_deployment_is_finalization_locked (deployment));
+ ul_jsonwrt_value_boolean (jo, "soft-reboot-target",
+ ostree_deployment_is_soft_reboot_target (deployment));
ul_jsonwrt_value_boolean (jo, "staged", ostree_deployment_is_staged (deployment));
ul_jsonwrt_value_boolean (jo, "pinned", ostree_deployment_is_pinned (deployment));
OstreeDeploymentUnlockedState unlocked = ostree_deployment_get_unlocked (deployment);
}
host_commit=$(rpmostree_query_json '.deployments[0].checksum')
host_osname=$(rpmostree_query_json '.deployments[0].osname')
+
+# $1 - json file
+# $2+ - assertions
+assert_jq() {
+ f=$1; shift
+ for expression in "$@"; do
+ if ! jq -e "${expression}" >/dev/null < $f; then
+ jq . < $f | sed -e 's/^/# /' >&2
+ echo 1>&2 "${expression} failed to match $f"
+ exit 1
+ fi
+ done
+}
+
+# Assert that ostree admin status --json matches the provided jq predicates.
+assert_status_jq() {
+ local t=$(mktemp --suffix=.json)
+ ostree admin status --json > $t
+ assert_jq $t "$@"
+ rm $t
+}
systemctl mask --now zincati
assert_streq $(systemctl show -P SoftRebootsCount) 0
+ assert_status_jq '.deployments[0].pending | not' '.deployments[0].["soft-reboot-target"] | not'
# Create a synthetic commit for upgrade
cd /ostree/repo/tmp
newcommit=$(ostree rev-parse soft-reboot-test)
# Deploy the new commit normally first
ostree admin deploy --stage soft-reboot-test
-
+
+ assert_status_jq '.deployments[0].pending' '.deployments[0].["soft-reboot-target"] | not'
+
# Test prepare-soft-reboot command
echo "Testing prepare-soft-reboot..."
ostree admin prepare-soft-reboot 0
-
+
+ # Test human readable format
ostree admin status > status.txt
assert_file_has_content_literal status.txt '(pending) (soft-reboot)'
+ # And via JSON
+ assert_status_jq '.deployments[0].pending' '.deployments[0].["soft-reboot-target"]'
+
+ # Verify the internal state file
test -f /run/ostree/nextroot-booted
/tmp/autopkgtest-soft-reboot "2"
exit 1
fi
+ assert_status_jq '.deployments[0].booted' '.deployments[0].["soft-reboot-target"] | not'
+
test -f /etc/new-file-for-soft-reboot
test -f /usr/share/test-file-for-soft-reboot